package com.sky.controller.user;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import com.sky.result.Result;
import com.sky.service.ShopCarService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/user/shoppingCart")
@RestController
@Slf4j
@Api(tags = "C端购物车接口")
public class ShopCarController {
    @Autowired
    ShopCarService shopCarService;
    @PostMapping("/add")
    public Result addcarshop(@RequestBody ShoppingCartDTO shoppingCartDTO){
        log.info("添加购物车:{}",shoppingCartDTO);
        shopCarService.addShopCar(shoppingCartDTO);
        return Result.success();
    }

    @GetMapping("/list")
    public Result<List<ShoppingCart>> list(){
        log.info("查看购物车：{}");
       List<ShoppingCart>  s=shopCarService.lookShopCart();
        return Result.success(s);
    }

    @DeleteMapping("/clean")
    public Result<String> cleancart(){
        log.info("清理购物车功能,{}");
        shopCarService.cleanshopcart();
        return Result.success();
    }


}
